<template>
	<div class="bg-white">
		<h1>房间新增</h1>
		<Form :label-width="80">
			<FormItem label="所属门店">
				<Select v-model="room.storeid">
					<Option :key="key" :value="item.storeid" v-for="(item, key) in mds">{{item.name}}</Option>
				</Select>
			</FormItem>
			<FormItem label="房间名">
				<Input v-model="room.roomname" placeholder="请输入房间名"></Input>
			</FormItem>
			<FormItem label="描述">
				<Input v-model="room.ms" placeholder="请输入描述"></Input>
			</FormItem>
			<FormItem label="房间单价">
				<Input v-model="room.price" placeholder="请输入房间单价/分钟"></Input>
			</FormItem>
			   <!-- <FormItem label="房间状态">
			   	<Select v-model="room.statu">
			   		<Option :key="key" :value="item.code" v-for="(item, key) in roomStatus">{{item.value}}</Option>
			   	</Select>
			   </FormItem> -->
			<FormItem class="text-right">
				<Button @click="submit" type="primary">提交</Button>
			</FormItem>
		</Form>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				room: {
					storeid: "",
					roomid: "",
					roomname: "",
					ms: "",
					price: "",
					//roomAFlg: ""
				},
				mds: [],//门店列表
				roomStatus: [],
			}
		},
		props: {
			params: {
				type: Object,
				default: undefined,
			}
		},
		
		
		mounted: function() {
		},
		created: function() {
			this.loadStore().then(this.loadRoomStatu);
			
		},
		methods: {
			
			submit: function() {

				// let pattern = /^[A-Z]+$/g;

				// if (this.role.roleCode.length === 0) {
				//   this.message.error("请输入角色编码");
				//   return;
				// } else if (!pattern.test(this.role.roleCode)) {
				//   this.message.error("角色编码只能是大写字母");
				//   return;
				// } else if (this.role.roleCode.length > 3) {
				//   this.message.error("角色编码最长3位");
				//   return;
				// }

				this.message.confirm({
					title: "保存提示",
					content: "即将新增房间，确定吗？",
					onOk: () => {
						this.http.post({
							url: "/room/info",
							param: {
								room: JSON.stringify(this.room)
							}
						}).then(res => {
							this.message.info("新增成功");
							this.$router.detail.close();
						});
					},
					onCancel: () => {
						this.message.info('操作已取消');
					}
				});
			},
			
			//加载门店名称
			loadStore: function() {
				return this.http.get({
					url: "/room/StoreName",
					param: {
					}
				}).then(data => {
					console.log(data);
					this.mds = data;
				});
			},
			
			//加载房间状态
			loadRoomStatu: function() {
				return this.http.get({
					url: "/dict/all",
					param: {
						type: "ROOMSTATU"
					}
				}).then(data => {
					this.roomStatus = data.fjstatusList;
				});
			},
			
		},
		
	}
</script>

<style>
</style>